home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / Multiprocessing.p < prev    next >
Encoding:
Text File  |  1997-08-12  |  6.0 KB  |  193 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        Multiprocessing.p
  3.  
  4.      Contains:    Multiprocessing interfaces
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1996-1997 by Apple Computer, Inc. and © 1995-1997 DayStar Digital, Inc.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT Multiprocessing;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __MULTIPROCESSING__}
  28. {$SETC __MULTIPROCESSING__ := 1}
  29.  
  30. {$I+}
  31. {$SETC MultiprocessingIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __CODEFRAGMENTS__}
  38. {$I CodeFragments.p}
  39. {$ENDC}
  40.  
  41.  
  42. {$PUSH}
  43. {$ALIGN POWER}
  44. {$LibExport+}
  45.  
  46. {$IFC TARGET_CPU_PPC }
  47.  
  48. CONST
  49.     MPLibrary_MajorVersion        = 1;
  50.     MPLibrary_MinorVersion        = 4;
  51.     MPLibrary_Release            = 1;
  52.     MPLibrary_DevelopmentRevision = 2;
  53.  
  54.  
  55. TYPE
  56.     MPTaskID = ^LONGINT;
  57.     MPQueueID = ^LONGINT;
  58.     MPSemaphoreID = ^LONGINT;
  59.     MPCriticalRegionID = ^LONGINT;
  60.     MPSemaphoreCount                    = UInt32;
  61.     MPTaskOptions                        = UInt32;
  62.     TaskProc = ProcPtr;  { FUNCTION TaskProc(parameter: UNIV Ptr): OSStatus; C; }
  63.  
  64.     MPRemoteProcedure = ProcPtr;  { FUNCTION MPRemoteProcedure(parameter: UNIV Ptr): Ptr; C; }
  65.  
  66.     MPPrintfHandler = ProcPtr;  { PROCEDURE MPPrintfHandler(taskID: MPTaskID; format: ConstCStringPtr; args: va_list); C; }
  67.  
  68.  
  69. CONST
  70.     kDurationImmediate            = 0;
  71.     kDurationForever            = $7FFFFFFF;
  72.  
  73.     kMPNoID                        = 0;
  74.  
  75.  
  76. FUNCTION MPProcessors: UInt32; C;
  77. FUNCTION MPCreateTask(entryPoint: TaskProc; parameter: UNIV Ptr; stackSize: ByteCount; notifyQueue: MPQueueID; terminationParameter1: UNIV Ptr; terminationParameter2: UNIV Ptr; options: MPTaskOptions; VAR task: MPTaskID): OSStatus; C;
  78.  
  79. FUNCTION MPTerminateTask(task: MPTaskID; terminationStatus: OSStatus): OSStatus; C;
  80.  
  81. PROCEDURE MPExit(status: OSStatus); C;
  82.  
  83. FUNCTION MPCurrentTaskID: MPTaskID; C;
  84.  
  85. PROCEDURE MPYield; C;
  86.  
  87. FUNCTION MPCreateQueue(VAR queue: MPQueueID): OSStatus; C;
  88.  
  89. FUNCTION MPDeleteQueue(queue: MPQueueID): OSStatus; C;
  90.  
  91. FUNCTION MPNotifyQueue(queue: MPQueueID; param1: UNIV Ptr; param2: UNIV Ptr; param3: UNIV Ptr): OSStatus; C;
  92.  
  93. FUNCTION MPWaitOnQueue(queue: MPQueueID; VAR param1: UNIV Ptr; VAR param2: UNIV Ptr; VAR param3: UNIV Ptr; timeout: Duration): OSStatus; C;
  94.  
  95. FUNCTION MPCreateSemaphore(maximumValue: MPSemaphoreCount; initialValue: MPSemaphoreCount; VAR semaphore: MPSemaphoreID): OSStatus; C;
  96.  
  97.  
  98. FUNCTION MPWaitOnSemaphore(semaphore: MPSemaphoreID; timeout: Duration): OSStatus; C;
  99.  
  100. FUNCTION MPSignalSemaphore(semaphore: MPSemaphoreID): OSStatus; C;
  101.  
  102. FUNCTION MPDeleteSemaphore(semaphore: MPSemaphoreID): OSStatus; C;
  103.  
  104. FUNCTION MPCreateCriticalRegion(VAR criticalRegion: MPCriticalRegionID): OSStatus; C;
  105.  
  106. FUNCTION MPEnterCriticalRegion(criticalRegion: MPCriticalRegionID; timeout: Duration): OSStatus; C;
  107.  
  108. FUNCTION MPExitCriticalRegion(criticalRegion: MPCriticalRegionID): OSStatus; C;
  109.  
  110. FUNCTION MPDeleteCriticalRegion(criticalRegion: MPCriticalRegionID): OSStatus; C;
  111.  
  112. FUNCTION MPAllocate(size: ByteCount): LogicalAddress; C;
  113. PROCEDURE MPFree(object: LogicalAddress); C;
  114.  
  115. PROCEDURE MPBlockCopy(sourcePtr: LogicalAddress; destPtr: LogicalAddress; blockSize: ByteCount); C;
  116.  
  117. {*************************************************************************
  118.  *
  119.  *    MPTaskIsToolboxSafe() and MPRPC() were functions added by DayStar. 
  120.  *    The 1.4 MPLibrary exports the names with an underscore prefix. 
  121.  *    To work around this, #defines have been added to automatically
  122.  *    add the underscore.
  123.  *
  124.  }
  125.     MPTaskIsToolboxSafe() allows routines which are otherwise unaware that 
  126.     they are being called from an MP task to check to see if it is permissible
  127.     to make a call to the Macintosh toolbox.  (It is okay to make toolbox 
  128.     calls only if the routine is not being called from an MP task).
  129. }
  130. FUNCTION MPTaskIsToolboxSafe(task: MPTaskID): BOOLEAN; C;
  131. {
  132.     MPRPC() calls its MPRemoteProcedure parameter in the application's main 
  133.     thread when the app next calls WaitNextEvent, EventAvail, SystemTask, 
  134.     MPYield, MPWaitOnQueue, MPWaitOnSemaphore, or MPEnterCriticalRegion. The  
  135.     return value of the MPRemoteProcedure is returned as the result of MPRPC.  
  136.     The MPRemoteProcedure function can call any toolbox function except  
  137.     SystemTask (or anything that calls it).
  138. }
  139. FUNCTION MPRPC(theProc: MPRemoteProcedure; parameter: UNIV Ptr): Ptr; C;
  140.  
  141.  
  142. {*************************************************************************
  143.  *
  144.  *    The following routines were added by DayStar for debugging purposes.
  145.  *    You should not use these in shipping products.  You can tell which
  146.  *    functions are for debugging only because they begin with an underscore
  147.  *
  148.  }
  149. FUNCTION _MPIsFullyInitialized: BOOLEAN; C;
  150.  
  151. {
  152.     MPAllocateSys() does the same thing as MPAllocate() except the memory
  153.     is allocated from the system heap.
  154. }
  155. FUNCTION _MPAllocateSys(size: ByteCount): LogicalAddress; C;
  156.  
  157. FUNCTION _MPLibraryIsCompatible(versionCString: ConstCStringPtr; major: UInt32; minor: UInt32; release: UInt32; revision: UInt32): BOOLEAN; C;
  158. PROCEDURE _MPInitializePrintf(pfn: MPPrintfHandler); C;
  159. PROCEDURE _MPPrintf(format: ConstCStringPtr; ...); C;
  160.  
  161. {
  162.      MPDebugStr() works just like DebugStr() except that it is safe
  163.     to call it from an MP task.
  164. }
  165. PROCEDURE _MPDebugStr(msg: ConstStr255Param); C;
  166. {
  167.  
  168.     MPStatusPString() and MPStatusCString() provide a way to translate an OSStatus
  169.     value returned from one of the MP API calls into either a Pascal string or a
  170.     C string.  Thus, if an MPLibrary function returns an error then the application
  171.     (not a task) could use the following:
  172.  
  173.     status = MPxxx( function_params );
  174.     DebugStr( MPStatusPString( status ) );
  175.     
  176. }
  177. FUNCTION _MPStatusPString(status: OSStatus): StringPtr; C;
  178. FUNCTION _MPStatusCString(status: OSStatus): ConstCStringPtr; C;
  179.  
  180. {$ENDC}  {TARGET_CPU_PPC}
  181.  
  182. {$ALIGN RESET}
  183. {$POP}
  184.  
  185. {$SETC UsingIncludes := MultiprocessingIncludes}
  186.  
  187. {$ENDC} {__MULTIPROCESSING__}
  188.  
  189. {$IFC NOT UsingIncludes}
  190.  END.
  191. {$ENDC}
  192.